/*年轻人，只管向前看，不要管自暴自弃者的话*/
package com.znb.okdown.flutter

import org.json.JSONObject


/**
 * create by itz on 2023/12/27 15:20
 * desc :
 **/
class PluginState {
    var method: String
    var arguments: Any

    constructor(method: String, arguments: Any) {
        this.method = method
        this.arguments = arguments
    }

    fun <T> argument(key: String): T? {
        return when (arguments) {
            null -> null
            is Map<*, *> -> (arguments as Map<*, *>)[key] as T?
            is JSONObject -> (arguments as JSONObject).opt(key) as T
            else -> throw ClassCastException()
        }
    }
}